<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

	<title>Module: RConfig::Callbacks</title>

	<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />

	<script src="../js/jquery.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../js/thickbox-compressed.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../js/quicksearch.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../js/darkfish.js" type="text/javascript"
		charset="utf-8"></script>

</head>
<body class="module">

	<div id="metadata">
		<div id="home-metadata">
			<div id="home-section" class="section">
        <h3 class="section-header">
          <a href="../index.html">Home</a>
          <a href="../index.html#classes">Classes</a>
          <a href="../index.html#methods">Methods</a>
        </h3>
			</div>
		</div>

		<div id="file-metadata">
			<div id="file-list-section" class="section">
				<h3 class="section-header">In Files</h3>
				<div class="section-body">
					<ul>
					
						<li><a href="../lib/rconfig/callbacks_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
							class="thickbox" title="lib/rconfig/callbacks.rb">lib/rconfig/callbacks.rb</a></li>
					
					</ul>
				</div>
			</div>

			
		</div>

		<div id="class-metadata">

			<!-- Parent Class -->
			

			<!-- Namespace Contents -->
			

			<!-- Method Quickref -->
			
			<div id="method-list-section" class="section">
				<h3 class="section-header">Methods</h3>
				<ul class="link-list">
					
					<li><a href="#method-i-fire_on_load">#fire_on_load</a></li>
					
					<li><a href="#method-i-on_load">#on_load</a></li>
					
				</ul>
			</div>
			

			<!-- Included Modules -->
			
		</div>

		<div id="project-metadata">
			
			
			<div id="fileindex-section" class="section project-section">
				<h3 class="section-header">Files</h3>
				<ul>
				
					<li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
				
				</ul>
			</div>
			

			<div id="classindex-section" class="section project-section">
				<h3 class="section-header">Class Index
					<span class="search-toggle"><img src="../images/find.png"
						height="16" width="16" alt="[+]"
						title="show/hide quicksearch" /></span></h3>
				<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
				<fieldset>
					<legend>Quicksearch</legend>
					<input type="text" name="quicksearch" value=""
						class="quicksearch-field" />
				</fieldset>
				</form>

				<ul class="link-list">
				
					<li><a href="../RConfig.html">RConfig</a></li>
				
					<li><a href="../RConfig/Callbacks.html">RConfig::Callbacks</a></li>
				
					<li><a href="../RConfig/Cascade.html">RConfig::Cascade</a></li>
				
					<li><a href="../RConfig/Config.html">RConfig::Config</a></li>
				
					<li><a href="../RConfig/ConfigError.html">RConfig::ConfigError</a></li>
				
					<li><a href="../RConfig/Constants.html">RConfig::Constants</a></li>
				
					<li><a href="../RConfig/CoreMethods.html">RConfig::CoreMethods</a></li>
				
					<li><a href="../RConfig/DisabledLogger.html">RConfig::DisabledLogger</a></li>
				
					<li><a href="../RConfig/Exceptions.html">RConfig::Exceptions</a></li>
				
					<li><a href="../RConfig/Generators.html">RConfig::Generators</a></li>
				
					<li><a href="../RConfig/Generators/InstallGenerator.html">RConfig::Generators::InstallGenerator</a></li>
				
					<li><a href="../RConfig/InvalidLoadPathError.html">RConfig::InvalidLoadPathError</a></li>
				
					<li><a href="../RConfig/LoadPaths.html">RConfig::LoadPaths</a></li>
				
					<li><a href="../RConfig/PropertiesFile.html">RConfig::PropertiesFile</a></li>
				
					<li><a href="../RConfig/Reload.html">RConfig::Reload</a></li>
				
					<li><a href="../RConfig/Settings.html">RConfig::Settings</a></li>
				
					<li><a href="../RConfig/Utils.html">RConfig::Utils</a></li>
				
					<li><a href="../Array.html">Array</a></li>
				
					<li><a href="../Hash.html">Hash</a></li>
				
					<li><a href="../NilClass.html">NilClass</a></li>
				
					<li><a href="../String.html">String</a></li>
				
				</ul>
				<div id="no-class-search-results" style="display: none;">No matching classes.</div>
			</div>

			
		</div>
	</div>

	<div id="documentation">
		<h1 class="module">RConfig::Callbacks</h1>

		<div id="description">
			
		</div>

		<!-- Constants -->
		

		<!-- Attributes -->
		

		<!-- Methods -->
		
		<div id="public-instance-method-details" class="method-section section">
			<h3 class="section-header">Public Instance Methods</h3>

		
			<div id="fire-on-load-method" class="method-detail ">
				<a name="method-i-fire_on_load"></a>

				<div class="method-heading">
				
					<span class="method-name">fire_on_load</span><span
						class="method-args">(name)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Executes all of the reload callbacks registered to the specified config
name, and all of the callbacks registered to run on any config, as
specified by the :ANY symbol.
</p>
					

					
					<div class="method-source-code"
						id="fire-on-load-source">
<pre>
    <span class="ruby-comment cmt"># File lib/rconfig/callbacks.rb, line 38</span>
38:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fire_on_load</span>(<span class="ruby-identifier">name</span>)
39:       <span class="ruby-identifier">procs</span> = (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">callbacks</span>[<span class="ruby-value str">'ANY'</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">RConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">EMPTY_ARRAY</span>) <span class="ruby-operator">+</span> (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">callbacks</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">RConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">EMPTY_ARRAY</span>)
40:       <span class="ruby-identifier">procs</span>.<span class="ruby-identifier">uniq!</span>
41:       <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;fire_on_load(#{name.inspect}): callbacks[#{procs.inspect}]&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">procs</span>.<span class="ruby-identifier">empty?</span>
42:       <span class="ruby-identifier">procs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">proc</span><span class="ruby-operator">|</span> <span class="ruby-identifier">proc</span>.<span class="ruby-identifier">call</span>() }
43:     <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="on-load-method" class="method-detail ">
				<a name="method-i-on_load"></a>

				<div class="method-heading">
				
					<span class="method-name">on_load</span><span
						class="method-args">(*args, &blk)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Register a callback when a config has been reloaded. If no config name is
specified, the callback will be registered under the name :ANY. The name
:ANY will register a callback for any config file change.
</p>
<p>
Example:
</p>
<pre>
  class MyClass
    self.my_config = { }
    RConfig.on_load(:cache) do
      self.my_config = { }
    end
    def my_config
      self.my_config ||= something_expensive_thing_on_config(RConfig.cache.memory_limit)
    end
  end</pre>
					

					
					<div class="method-source-code"
						id="on-load-source">
<pre>
    <span class="ruby-comment cmt"># File lib/rconfig/callbacks.rb, line 21</span>
21:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_load</span>(*<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">blk</span>)
22:       <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:ANY</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
23:       <span class="ruby-identifier">proc</span> = <span class="ruby-identifier">blk</span>.<span class="ruby-identifier">to_proc</span>
24: 
25:       <span class="ruby-comment cmt"># Call proc on registration.</span>
26:       <span class="ruby-identifier">proc</span>.<span class="ruby-identifier">call</span>()
27: 
28:       <span class="ruby-comment cmt"># Register callback proc.</span>
29:       <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
30:         (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">callbacks</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">||=</span> []) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">proc</span>
31:       <span class="ruby-keyword kw">end</span>
32:     <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	

	</div>


	<div id="rdoc-debugging-section-dump" class="debugging-section">
	
		<p>Disabled; run with --debug to generate this.</p>
	
	</div>

	<div id="validator-badges">
		<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
		<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
			Rdoc Generator</a> 1.1.6</small>.</p>
	</div>

</body>
</html>

